import ajax from './ajax'

// 根据经纬度获取位置详情
// http://localhost:3000/position/:geohash
export const reqAddress = (geohash) => ajax('/api/position/' + geohash)

// 获取食品分类列表
// http://localhost:3000/index_category
export const reqCategory = () => ajax('/api/index_category')

// 根据经纬度获取商铺列表
// http://localhost:3000/shops?latitude=40.10038&longitude=116.36867
export const reqShops = ({ latitude, longitude }) => ajax('/api/shops', { latitude, longitude })


// 用户名密码登陆
// http://localhost:3000/login_pwd
export const reqPwdLogin = (name, pwd, captcha) => ajax('/api/login_pwd', { name, pwd, captcha }, 'POST')

// 发送短信验证码
// http://localhost:3000/sendcode
export const reqSendCode = phone => ajax('/api/sendcode', { phone })

// 手机号验证码登陆
// http://localhost:3000/login_sms
export const reqSmsLogin = (phone, code) => ajax('/api/login_sms', { phone, code }, 'POST')

// 根据会话获取用户信息
// http://localhost:3000/userinfo
export const reqUserInfo = () => ajax('/api/userinfo')

// 用户登出
// http://localhost:3000/logout
export const reqLogout = () => ajax('/api/logout')

// 获取shopGoods数据
export const reqShopGoods = () => ajax('/goods')

// 获取ShopRatings数据
export const reqShopRatings = () => ajax('/ratings')

// 获取ShopInfo 数据
export const reqShopInfo = () => ajax('/info')

// 根据关键字搜索相关商家数组
export const reqSearchGoods = (geohash, keyword) => ajax('/api/search_shops', {geohash, keyword})